package com.dtx.algorithm.horse;

public class HorseChessboard {
    public static void main(String[] args) {
        System.out.println("骑士周游算法，开始运行~~");
        //测试骑士周游算法是否正确
        HorseChess.X = 8;
        HorseChess.Y = 8;
        int row = 1; //马儿初始位置的行，从1开始编号
        int column = 1; //马儿初始位置的列，从1开始编号
        //创建棋盘
        int[][] chessboard = new int[HorseChess.X][HorseChess.Y];
        HorseChess.visited = new boolean[HorseChess.X * HorseChess.Y];//初始值都是false
        //测试一下耗时
        long start = System.currentTimeMillis();
        HorseChess.traversalChessboard(chessboard, row - 1, column - 1, 1);
        long end = System.currentTimeMillis();
        System.out.println("共耗时: " + (end - start) + " 毫秒");

        //输出棋盘的最后情况
        for(int[] rows : chessboard) {
            for(int step: rows) {
                System.out.print(step + "\t");
            }
            System.out.println();
        }
    }
}
